package com.example.ksproomdemo.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.ksproomdemo.bean.User

/**
 * @author: njb
 * @date:   2025/3/30 1:06
 * @desc:   描述
 */
@Dao
interface UserDao {
    @Query("SELECT * FROM user")
    suspend fun getAll(): List<User>

    @Query("SELECT * FROM user WHERE id IN (:userIds)")
    suspend fun loadAllByIds(userIds: IntArray): List<User>

    @Query("SELECT * FROM user WHERE name LIKE :name")
    suspend fun findByName(name: String): User?

    @Query("SELECT *FROM user WHERE id LIKE:userId")
    suspend fun findById(userId: Int): User?

    @Update
    suspend fun updateUser(user: User)

    @Insert
    suspend fun insertAll(users: User)

    @Delete
    suspend fun delete(user: User)

    @Delete
    suspend fun deleteUsers(user: List<User>)

    @Query("DELETE FROM User")
    suspend fun deleteAllUserInfo()
}